<?php
/**
 * Instagram Rss Builder
 * BY AntDz
 * 2015-11-18
 (c) Copyright 2015 Administrator. All Rights Reserved.
 * */
require ('rssbuilder.class.php');

header('Content-Type: application/xml; charset=utf-8');
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Fri, 14 Mar 1980 20:53:00 GMT');
header('Last-Modified: ' . date('r'));
header('Pragma: no-cache');

$rss = new RSSBuilder('utf-8', 'http://antdz.iteye.com', 'Instagram RSS', 'Instagram RSS BY AntDz');
$rss -> addDCdata('http://antdz.iteye.com', 'http://antdz.iteye.com', date('r'));
$ver = '2.00'; //rss版本

 /*file_get_contents()读取json
$jsondata = file_get_contents("https://api.instagram.com/v1/users/self/feed?access_token=545490633.2e7067c.2d7378e20775421fadac61fc778965c8");
$arraydata = json_decode($jsondata, TRUE);
$usedata = $arraydata['data'];*/
//获取数组中的data

/*curl读取json*/
require_once ("Instagram.class.php");
$instagram = Instagram::getFeed2('545490633.2e7067c.2d7378e20775421fadac61fc778965c8');
$usedata=$instagram['data'];

foreach ($usedata as $val) {
	$name = "";
	if ($val['user']['full_name'] == "") {
		$name = $val['user']['username'];
	} else {
		$name = $val['user']['full_name'];
	}
	$rss -> addItem('', "<![CDATA[" . $val['caption']['text'] . "]]>", $val['link'], "<![CDATA[" . $val['caption']['text'] . "<br><img  src='" . $val['images']['low_resolution']['url'] . "'/>]]>", $val['type'], date('r', $val['created_time']), "<![CDATA[" . $name . "]]>");
}
$rss -> outputRSS($ver);
?>